package com.zsck.pos.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.chinaums.commoncheck.R;
import com.zsck.pos.bean.Record;

import java.util.List;


public class RecordAdapter extends BaseAdapter {
    private Context mContext;
    private List<Record> mRecords;
    public RecordAdapter(Context context,List<Record> records){
        this.mContext = context;
        this.mRecords = records;
    }

    @Override
    public int getCount() {
        return mRecords.size();
    }

    @Override
    public Record getItem(int position) {
        return mRecords.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if(convertView == null){
            convertView = View.inflate(mContext, R.layout.item_record,null);
            holder = new ViewHolder();
            holder.tvName = convertView.findViewById(R.id.tv_name);
            holder.tvStatus = convertView.findViewById(R.id.tv_status);
            holder.tvProject = convertView.findViewById(R.id.tv_project);
            holder.tvMoney = convertView.findViewById(R.id.tv_money);
            holder.tvCost = convertView.findViewById(R.id.tv_cost);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }

        Record item = getItem(position);
        holder.tvName.setText(item.getRoomName());
        holder.tvStatus.setText("支付成功");
        holder.tvProject.setText(item.getProjectName());
        holder.tvCost.setText(item.getName());
        holder.tvMoney.setText(item.getTotalFee() + "");
        return convertView;
    }
    static class ViewHolder{
        TextView tvName;
        TextView tvStatus;
        TextView tvProject;
        TextView tvMoney;
        TextView tvCost;
    }
}
